#ifndef __HEAD_H__
#define __HEAD_H__

#define _XOPEN_SOURCE
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<unistd.h>
#include<dirent.h>
#include<errno.h>
#include<pwd.h>
#include<grp.h>
#include<fcntl.h>
#include<time.h>
#include<sys/mman.h>
#include<sys/wait.h>
#include<signal.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<pthread.h>
#include<netdb.h>
#include<arpa/inet.h>
#include<sys/socket.h>
#include<sys/epoll.h>
#include<sys/uio.h>
#include<sys/sendfile.h>

#define BUF_SIZE 128



#define ARGS_CHECK(argc, num)\
    do{\
        if(argc != num){\
            fprintf(stderr, "invalid arguments: expect %d arguments\n", num);\
            exit(1);\
        }\
    }while(0)

#define ERROR_CHECK(val, expectedval, msg)\
    do{\
        if(val == expectedval){\
            perror(msg);\
            exit(1);\
        }\
    }while(0)

#define SIZE(a) (sizeof(a) / sizeof(a[0]))

#define THREAD_ERROR_CHECK(err, msg)\
    do{\
        if(err != 0){\
            fprintf(stderr, "%s: %s\n", msg, strerror(err));\
        }\
    }while(0)


#endif
